package com.jn.exam.paperConsumer.service.impl;

import com.jn.exam.paperConsumer.entity.PaperQuestionAnswer;
import com.jn.exam.paperConsumer.mapper.PaperQuestionAnswerMapper;
import com.jn.exam.paperConsumer.service.PaperQuestionAnswerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 学生答题答案 服务实现类
 * </p>
 *
 * @author 江南大学1033190417
 * @since 2022-02-21
 */
@Service
public class PaperQuestionAnswerServiceImpl extends ServiceImpl<PaperQuestionAnswerMapper, PaperQuestionAnswer> implements PaperQuestionAnswerService {

    @Override
    public boolean saveTotalScore(String examId, String studentId, Float totalScore) {
        Map<String, Object> param = new HashMap<>();
        param.put("examId", examId);
        param.put("studentId", studentId);
        param.put("totalScore", totalScore);
        return baseMapper.saveTotalScore(param);
    }

    @Override
    public boolean saveOrUpdateAnswer(PaperQuestionAnswer paperQuestionAnswer) {
        return baseMapper.saveOrUpdateAnswer(paperQuestionAnswer);
    }

    @Override
    public List<Map<String, Object>> getStatisticalOfOnePaperQuestion(String paperQuestionId) {
        return baseMapper.getStatisticalOfOnePaperQuestion(paperQuestionId);
    }

    @Override
    public List<Map<String, Object>> getMaxMinAvgOfOnePaperQuestion(String paperQuestionId) {
        return baseMapper.getMaxMinAvgOfOnePaperQuestion(paperQuestionId);
    }
}
